package q900_q1000;

/**
 * @Author: wzp
 * @CreateTime: 2024-09-22  10:06
 * @Description: TODO
 * @Version: 1.0
 */






public class q_997 {
    public int findJudge(int n, int[][] trust) {
        int [] believed=new int[trust.length+1];
        int [] t_other=new int[trust.length+1];
        for (int i = 0; i < trust.length; i++) {
            t_other[trust[i][0]]++;
            believed[trust[i][1]]++;
        }
        int index=-1;
        for (int i = 1; i <= n; i++) {
            if(believed[i]==n-1&&t_other[i]==0){
                index=i;
                break;
            }
        }
        return index;

    }
}
